package com.ddzh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddzh.pojo.Order;
import com.ddzh.res.OrderRes;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT m.name member,\n" +
            "       s.name setmeal,\n" +
            "       DATE_FORMAT(o.order_date,'%Y-%m-%d') order_date,\n" +
            "       (\n" +
            "       CASE\n" +
            "       WHEN o.order_type = 0 THEN '微信'\n" +
            "       ELSE '电话'\n" +
            "       END\n" +
            "       ) order_type\n" +
            "FROM order_t o \n" +
            "LEFT JOIN member m ON o.member_id=m.id\n" +
            "LEFT JOIN setmeal_t s ON o.setmeal_id=s.id\n" +
            "WHERE o.id=#{orderId};")
    OrderRes getOrderRes(@Param("orderId") Long orderId);
}
